<template>
    <div>
        <h3>上架商品</h3>
        <el-table
                :data="tableData.slice((currentPage-1)*PageSize,currentPage*PageSize)" style="width: 100%">
            <el-table-column
                    prop="goodscode"
                    label="商品编号">
            </el-table-column>
            <el-table-column
                    prop="goodsname"
                    label="商品名称">
            </el-table-column>
            <el-table-column
                    prop="goodsbatch"
                    label="批次">
            </el-table-column>
            <el-table-column
                    prop="number"
                    label="销售数量">
            </el-table-column>
            <el-table-column
                    prop="goodstype"
                    label="商品类型">
            </el-table-column>
            <el-table-column
                    prop="goodsspecs"
                    label="商品规格">
            </el-table-column>
            <el-table-column
                    prop="goodspricce"
                    label="售价">
            </el-table-column>
            <el-table-column
                    prop="goodsstate"
                    label="状态">
            </el-table-column>
        </el-table>
        <div class="tabListPage">
            <div class="tabListPage">
                <el-pagination @size-change="handleSizeChange"
                               @current-change="handleCurrentChange"
                               :current-page="currentPage"
                               :page-sizes="pageSizes"
                               :page-size="PageSize" layout="total, sizes, prev, pager, next, jumper"
                               :total="totalCount">
                </el-pagination>
            </div>
            <el-button type="text"  size="small" id="bu" @click="returns">返回</el-button>
            <el-button type="text"  size="small" id="bb" @click="sures">确认</el-button>
        </div>
    </div>
</template>

<script>
    export default {
        name: "goodsShelvesViews",
        data() {
            return {
                tableData:[],
                totalCount:null,
                currentPage:1,
                pageSizes:[1,2,3,4],
                PageSize:3,
            }
        },
        mounted() {
            this.init()
        },
        methods: {
            handleSizeChange(val) {
                this.PageSize=val
                this.currentPage=1
            },
            handleCurrentChange(val) {
                this.currentPage=val
            },
            init(){
                this.$axios.get("/sscsys/shelves/findAllShelves").then(resp =>{
                    this.tableData = resp.data
                    this.totalCount=resp.data.length;
                })
            },
            returns(){
                this.$router.push("BatchView")
            },
            sures(){
                this.axios.post("/sscsys/shelves/commodity").then(resp =>{
                      if(resp.data == ""){
                         console.log("成功")
                          this.$router.push("BatchView")
                      }
                      else {
                          console.log("失败")
                      }
                })
            },
        }
    }
</script>
<style scoped>
  #bu{
      position: relative;
      left: 900px;
  }
  #bb{
      position: relative;
      left: 700px;
  }
</style>